import {createRouter,createWebHashHistory} from "vue-router"
// 1.声明routes配置
let routes=[
    {
        path:"/",
        component:()=>import("../pages/home/index.vue"),
        // 具名路由
        name:"/",
        // 路由元信息
        meta:{
            name:"导航首页"
        },
        // 嵌套路由，path里不加/
        children:[
            {
                path:"discover",
                component:()=>import("../pages/discover/index.vue"),
                name:"discover",
                meta:{
                    name:"发现首页"
                },
                // 重定向，当跳转到discover页面上时，自动到playlist页面
                redirect: "/discover/playlist",
                children:[
                    {
                        path:"playlist",
                        component:()=>import("../pages/discover/playlist/index.vue"),
                        name:"playlist",
                        meta:{
                            name:"歌单"
                        },
                    }
                ]
            },
            {
                path:"friend",
                component:()=>import("../pages/friend/index.vue"),
                name:"friend",
                meta:{
                    name:"朋友"
                },
            },
            {
                path:"mine",
                component:()=>import("../pages/mine/index.vue"),
                name:"mine",
                meta:{
                    name:"个人中心"
                },
            }
        ]
    },
    {
        path:"/login",
        component:()=>import("../pages/login/index.vue"),
        name:"login",
        meta:{
            name:"登录页"
        },
    } 
]
// 2.创建路由
const router = createRouter({
    history:createWebHashHistory("/base"),
    routes
})
// 3.导出路由
export default router